<%@ page language="java"
import="java.util.*,com.wechat.service.WechatService,
com.base.bean.*,com.base.dao.*,com.base.service.*,tool.*"
pageEncoding="UTF-8"%>
<%
//注意生成注入对象的时候 一定要去掉端口号
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() +  path + "/"; %>
<%
WechatService ws = WechatService.getInstance();
//String url = basePath + "user_daka.jsp";
String url = basePath + "showDaka"; 
%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %> 
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HIFO</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/main.css">   
<script src="lib/jquery-2.1.1.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
</head>
<body>  

<!-- 每个页面的模板，以下是正文 -->    
<div class="container"><div class="row">
<div class="col-xs-12">
<form id="form1" action="daka.action">
<input id="longitude" name="longitude"  type="text" class="">
<input id="latitude" name="latitude" type="text" class="">
</form><!-- 隐藏域 传递数据用  -->
</div><!-- col-xs-12 -->

<div class="panel panel-default">
<div class="panel-heading"><s:property value="datetime"/></div>
<div  class="panel-body">

<% 
//List<UserDaka> dks;
//DakaService ds=DakaService.getInstance();
//String begin=TimeTool.getTodayBeginStr();
//dks=ds.getDkDao().findByHql("from UserDaka d where d.uid="+1+" and d.created>='"+begin+"'");
%>

<s:iterator value="dks" id="dk" status="index">
<div>第<s:property value="#index.index+1"/>次打卡</div>
<div><span><s:property value="#dk.created"/></span><span><s:property value="#dk.addName"/></span></div>
</s:iterator>

<!--  
<div>第1次打卡</div>
<div><span>09：30</span><span>成都市新都区</span></div>
-->

</div><!-- panel-body -->

<div class="panel-footer">
<button class="btn btn_primary" id="check">检查</button>
<button class="btn btn_primary" id="daka">打卡</button>
</div></div><!-- panel-footer panel-default -->

</div></div><!-- row container  -->

</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script><%=ws.wxConfig(url) %></script>
<script>
wx.ready(function () {
// 1 判断当前版本是否支持指定 JS 接口，支持批量判断
document.querySelector('#check').onclick = function () {
wx.checkJsApi({
jsApiList: [
'getNetworkType',
'previewImage'
],
success: function (res) {
alert(JSON.stringify(res));
}
});
};
 

document.querySelector('#daka').onclick = function () {
wx.getLocation({
type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
success: function (res) {
alert(JSON.stringify(res));
$('#longitude').val(res.longitude);
$('#latitude').val(res.latitude);
alert('提交');
$("#form1").submit();
},
cancel: function (res) {
alert('用户拒绝授权获取地理位置');
}
});
};
});
wx.error(function (res) {
alert(res.errMsg);
});
</script>
</html>
